// JavaScript Document

function layer_show(layer_name,action){
if(action=="show"){
   document.getElementById(layer_name).style.display="block";
}
else if(action=="hide"){
   document.getElementById(layer_name).style.display="none";
}

}
function chg_btn(num){
	var id_name="button"+num;
	var tr_name="content"+num;
	for(i=1;i<=7;i++){
		document.getElementById("button"+i).className="";
		document.getElementById("content"+i).style.display="none";
	}
	document.getElementById(id_name).className="ondate";
	document.getElementById(tr_name).style.display="block";
}

function rd_chg_btn(num){
	var id_name="id_lineType"+num;
	var tr_name="rd_content"+num;
	for(i=1;i<=2;i++){
		document.getElementById("id_lineType"+i).className="";
		document.getElementById("rd_content"+i).style.display="none";
	}
	document.getElementById(id_name).className="";
	document.getElementById(tr_name).style.display="block";
}

function godatechg_btn(num){
	var id_name="godate_button"+num;
	var tr_name="godate_content"+num;
	for(var i=1;i<=2;i++){
		document.getElementById("godate_button"+i).className="wangfan";
		document.getElementById("godate_content"+i).style.display="none";
	}
	
	if(num==2){
		document.getElementById(id_name).className = "wangfan";
		document.getElementById(tr_name).style.display= "block";
	}
	
	
/*	$("td[name='more_price']").each(function(){
		if(num == 1){
			$(this).attr("style","display:"); 
		}
		if(num == 2){
			$(this).attr("style","display:none"); 
		}		
	}); */
}
(function(){
	//验证
	var formValid = {
		trim : function(val){
			return val.replace(/^\s+|\s+$/g, "");
		},
		isDate : function(str){
			var reg = /(?:[19|20]\d{2})-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12][0-9]|3[01])/;
			return reg.test(str) && str.length == 10;
		},
		compareDate : function(d1, d2, str){
			var d1arr = d1.split(str), d2arr = d2.split(str);
			return (d2arr[0]>d1arr[0] || (d2arr[0]==d1arr[0] && d2arr[1]>d1arr[1]) || (d2arr[0]==d1arr[0] && d2arr[1]==d1arr[1] && d2arr[2]>d1arr[2])) ? 1 : 0;
		}
	};
	
	//加载天数
	function addDay(num, date){
		var now = date ? new Date(date.getFullYear(), date.getMonth(), date.getDate()) : new Date();
		var olddate = now.getDate();
		now.setDate(now.getDate()+num);
		return now.getFullYear() + '-' + ((now.getMonth()+1)<10 ? "0"+(now.getMonth()+1): (now.getMonth()+1))+'-'+ (now.getDate()<10 ? "0"+now.getDate() :now.getDate());
	}	
		
	// 根据城市获取三字码
	function getThreeWordByCity(cityName,flag){
		var commoncitys, citys, threeWord = "";
		if(flag!=undefined&&flag!=null&&flag=="hotel"){
		   commoncitys = commoncitysHotel;
		   citys = citysForHotel;
		}else if(flag!=undefined&&flag!=null&&flag=="flight"){
		   commoncitys = commoncitysFlight;
		   citys = citysForFlight;
		}
		for(var i = 0,len = citys.length;i<len;i++){
			if(cityName == citys[i][1]){
				threeWord = citys[i][0];
				break;
			}
		}
		return threeWord;
	}	
	
	
	// 检索变量
	
    var id_startDate = MGTOOL.$id('id_startDate'),
        id_backDate = MGTOOL.$id('id_backDate'),
        id_lineType1 = MGTOOL.$id('id_lineType1'),
		id_lineType2 = MGTOOL.$id('id_lineType2'),
		id_research = MGTOOL.$id('id_research'),
		id_hotelSearch = MGTOOL.$id('id_hotelSearch'),
		gnhotel = MGTOOL.$id('gnhotel'),
		gahotel = MGTOOL.$id('gahotel');
		
		if(id_startDate && id_backDate){
			if(id_startDate.value == '') {
				id_startDate.value = addDay(1);
			}
			if (id_backDate.value == '') {
				id_backDate.value = addDay(2);
			}
			var flightstart = new Datepicker(id_startDate, {eachW:206,ttMonth:2, addDays:360, callback:callhoteldatestart}),
			
			   firstDate = id_startDate.value.split('-'), //获取起始日期数据
			   today = (!!firstDate.length) ? new Date(firstDate[0], firstDate[1]-1, firstDate[2]) : new Date(),//去开始日期时间作为结束日期的起始时间,否则以今天开始
			   f_s_Date = addDay(1, today).split('-'),
			   diffDays = Math.ceil((today-new Date())/86400000), //获取开始日期距离今天的时间差
			   f_e_Date = addDay(360, new Date()).split('-'); //默认开始日期的endDate
			   
		    var flightend = new Datepicker(id_backDate, {eachW:206,ttMonth:2, startDate:[f_s_Date[0], (f_s_Date[1]-1), f_s_Date[2]], addDays:parseInt(120+diffDays), endDate:f_e_Date, callback:callhoteldateend});
			
		}

		
	// 定义日历控件回调函数
	function callhoteldatestart(o, t){
	    o.value = t.title;
		o.style.color = '#333';
		
		var firstDate = o.value.split('-');
		var sdd = new Date(firstDate[0], firstDate[1]-1, firstDate[2]);
		var f_s_Date = addDay(1, sdd).split('-');
		
		id_backDate.value = addDay(1, sdd); //结束日期始终比开始日期晚一天
		var diffDays = Math.ceil((sdd-new Date())/86400000); //获取开始日期距离今天的时间差
		var f_e_Date = addDay(120, new Date()).split('-');
		flightend = new Datepicker(id_backDate, {eachW:206,ttMonth:2, startDate:[f_s_Date[0], (f_s_Date[1]-1), f_s_Date[2]], addDays:parseInt(120+diffDays), endDate:f_e_Date, callback:callhoteldateend});
		if(MGTOOL.$id('godate_content2').style.display === 'block'){
		    window.setTimeout(function(){id_backDate.focus();}, 0);
		}
		
		
		
		//id_backDate.focus();
	}
	
	function callhoteldateend(o, t){
	    o.value = t.title;
		o.style.color = '#333';
	}			
		
		
		// 机票单返程
		var lineType = 'ow';
		if(id_lineType1 && id_lineType2){

			id_lineType1.onfocus = id_lineType1.onclick = function(){
				lineType = 'ow';
			};
			id_lineType2.onfocus = id_lineType2.onclick = function(){
				lineType = 'rt';
			};

		}	
	    
		// 机票表单验证
		if(id_research){
            MGTOOL.$id('id_queryFlightForm').onsubmit = function(e){
			    MGTOOL.preventDefault(e);
			};
			
			id_research.onclick = function(){
				var lt = MGTOOL.$id('id_lineType1'),
					sc = MGTOOL.$id('id_startCity'),
					ec = MGTOOL.$id('id_endCity'),
					sd = MGTOOL.$id('id_startDate'),
					bd = MGTOOL.$id('id_backDate');
					startCity = formValid.trim(sc.value),
					endCity = formValid.trim(ec.value),
					startDate = formValid.trim(sd.value),
					backDate = formValid.trim(bd.value);
				if(getThreeWordByCity(startCity,"flight") == ""){
				   alert("请填写正确的出发城市");
				   window.setTimeout(function(){sc.focus(); }, 10);
				   
				}else if(getThreeWordByCity(endCity,"flight") == ""){
				   alert("请填写正确的到达城市");
				   window.setTimeout(function(){ec.focus(); }, 10);
				}else if(getThreeWordByCity(startCity,"flight") == getThreeWordByCity(endCity,"flight")){
				   alert("出发城市与到达城市不能同名");
				   ec.value = "";
				   MG.Dom.next(ec).value = "";
				   window.setTimeout(function(){ec.focus(); }, 10);
				}else if(!formValid.isDate(startDate)){
				   alert("请填写正确的出发日期");
				   sd.value = "";
				   window.setTimeout(function(){sd.focus();}, 10);
				}else if(lineType == "rt" && !formValid.isDate(backDate)){
				   alert("请填写正确的返程日期");
				   bd.value = "";
				   window.setTimeout(function(){bd.focus();}, 10);
				}else if(lineType == "rt" && !formValid.compareDate(startDate, backDate, '-')){
				   alert("返程日期应晚于出发日期");
				   bd.value = "";
				   window.setTimeout(function(){bd.focus();}, 10);
				}else{
				   saveHistory();
				   //MGTOOL.preventDefault(e);
				   //return;
				   MGTOOL.$id('id_queryFlightForm').submit();   
				}			
			};

		}

	
	
	

})();


/***************
* 30天低价机票
* zhongweiming 2011-11-08
* start
***************/


MGTOOL.isFunction = function(fn){return !!fn && !fn.nodeName && fn.constructor != String && fn.constructor != RegExp && fn.constructor != Array && /function/i.test( fn + "" );};
MGTOOL.loadScript = function (url, fn){
    var doc = window.document;
	var scripts = doc.getElementsByTagName('script');
	//判断指定的文件是否已存在，如果已存在则触发onsuccess事件并返回
	for(var i=0, len=scripts.length; i<len; i++){
		if(scripts[i].src && scripts[i].src.indexOf(url)!=-1){
			if(MGTOOL.isFunction(fn)){
				fn();
			}
			return;
		}
	}



    var script = doc.createElement('script');
    script.type = 'text/javascript';
    if(script.readyState){
        script.onreadystatechange = function(){
            if(script.readyState =='loaded' || script.readyState =='complete'){
                script.onreadystatechange = null;
                if(MGTOOL.isFunction(fn)){
                    fn();
                }
             }
        }
    }else{
	    script.onload = function(){
		    if(MGTOOL.isFunction(fn)){
		        fn();
			}
		};
	}
	script.src = url;
	doc.getElementsByTagName('head')[0].appendChild(script);
};

// 根据机票城市获取三字码
function getFlightThreeWordByCity(cityName){
	var commoncitys, citys, threeWord = "";
	    commoncitys = commoncitysFlight;
	    citys = citysForFlight;
	for(var i = 0,len = citys.length;i<len;i++){
		if(cityName == citys[i][1]){
			threeWord = citys[i][0];
			break;
		}
	}
	return threeWord;
}

//var s_threeword = MGTOOL.$id('id_dpt_02').value || getFlightThreeWordByCity(MGTOOL.$id('id_startCity_02').value),
//    e_threeword = MGTOOL.$id('id_arr_02').value || getFlightThreeWordByCity(MGTOOL.$id('id_endCity_02').value);
/*	
window.onload = function(){
    f_get_30datas(s_threeword);
};
*/

(function($){
  $.fn.MG_cycle_scroll=function(options){
     var options=jQuery.extend({
	    druation:2000,
		interval:5000
	 },options||{});

  return this.each(function(){
    var self=this;
	var tag=true;
	var timer;
	var child=$(self).children();
	var children=$(self).children().children(":first");
	var scrollH=children.outerHeight(true);
	function bindAnim(){
	   if(tag){
	      child.css({top:'0px'});
		  child.stop().animate({top:'-'+scrollH+"px"},{
		  duration:options.druation,
		  complete:function(){
			$(self).children().children(":first").appendTo(child);
			child.css({top:'0px'});
			if(timer){clearTimeout(timer);}
			timer = setTimeout(function(){bindAnim();},options.interval);
		  }
		  });
		} 
	} 
	$(self).hover(function(){tag=false;},function(){tag=true;bindAnim()});
	 timer = setTimeout(function(){bindAnim();},options.interval);
  });
  }
});



function f_get_30datas(key){
    if(!!key &&  typeof key === 'string'){
	    var url = 'http://fres.mangocity.com/js/flights/staticFile/flightShouye/'+ key +'-flight_shouye.js';
	    //var url = key +'-flight_shouye.js';
	    MGTOOL.loadScript(url, function(){
		   // e_threeword = MGTOOL.$id('id_arr_02').value || getFlightThreeWordByCity(MGTOOL.$id('id_endCity_02').value);
		   // MGTOOL.f_set_30datas(key, e_threeword, f_failer_tip);
		});
		MGTOOL.$id('goct').focus();
		MGTOOL.$id('goct').checked = true;
	}
}

function f_e_30datas(key){
    if(!!key &&  typeof key === 'string'){
	    //s_threeword = MGTOOL.$id('id_dpt_02').value || getFlightThreeWordByCity(MGTOOL.$id('id_startCity_02').value);
	    //var url = 'http://fres.mangocity.com/js/flights/staticFile/flightShouye/'+ s_threeword +'-flight_shouye.js';
	    //MGTOOL.loadScript(url, function(){
		  //  MGTOOL.f_set_30datas(s_threeword, key, f_failer_tip);
		//});	
		MGTOOL.$id('goct').focus();
		MGTOOL.$id('goct').checked = true;
	}
}


function f_failer_tip(txt){
    if(!MGTOOL.$id('tipspanel')){
    var div = document.createElement('div');
	div.id = 'tipspanel';
	div.className = 'tipspanel';
	div.innerHTML = txt || '出发城市与到达城市没有航线，请重新输入！';
	
	document.body.appendChild(div);
	}
	var el = MGTOOL.$id('tipspanel');
	var input = MGTOOL.$id('id_endCity_02');
	
	el.style.display = 'block';
	var pos = MGTOOL.getoffset(input),
		py = pos.top, 
		px = pos.left, 
		st = document.documentElement ? document.documentElement.scrollTop : document.body.scrollTop, 
		th = input.offsetHeight, 
		oh = el.offsetHeight, 
		dch = document.documentElement.clientHeight;
	//console.log(dch);
	if(py-st+oh>dch && py-st>oh){
		y = py-th-oh;
		el.style.left = px + "px";
		el.style.top = y + "px";
	}else{
		y = py+th;
		el.style.left = px + "px";
		el.style.top = y + "px";
	}
	
}


MGTOOL.f_set_30datas = function(){

	function setDateString(s_tw, e_tw, faler){
		
		//yyp S  如果没数据 提示都不提示了，直接全部显示“暂无价格”
		var allArr;
		try{
		allArr = eval('(' + s_tw+'_JSON' + ')');
		var priceArr = allArr[s_tw+'-'+e_tw];
		var lowestPrice=getlowprice(priceArr);//计算出的最低价格
		var shortchar = s_tw+'-'+e_tw;
		renderStrLi(priceArr,shortchar,lowestPrice);
		}catch(e){} 

	}
	//渲染面板
	function renderStrLi(priceList,shortChar,lowestPrice){//调用入口，第一参数是 绑定的数据源，第而参数是  起始城市与结束城市三字码字符串（如 "PEK-TSD"）
		 var today=new Date();
		 var week=calculatDate(formatTime(today),24*60*60*1000).getDay();
		 var dateIndex=formatTime(today);//今天的前一天；
		 var liIndex=1;
		 var liStr="";
		 var liNum=0;
		 var limitDate=formatTime(calculatDate(dateIndex,30*24*60*60*1000));//按今天后29天来计算的，即面板会显示总共30天的数据
		//构造前边空的li标签
		for(var i=0;i<week;i++){
		   liStr+="<li><div><span>&nbsp;</span><em>&nbsp;</em></div></li>";
		   liNum++;
		}
		//构造中间有数据的li标签
		if(typeof priceList=='undefined'||priceList.length=='0'){
		 var literal=dataInterval(dateIndex,limitDate);
		   for(var j=1;j<=literal;j++){
				  dateIndex=formatTime(calculatDate(dateIndex,24*60*60*1000));
				  liStr+=renderNonePrice(dateIndex.slice(-5));
				  liNum++; 
		   }
		}else{
				for(var i=0;i<priceList.length;i++){
				   var cutDate=0, literal=dataInterval(dateIndex,priceList[i][0]);
				   for(var j=1;j<=literal;j++){
						  var Dobj=calculatDate(dateIndex,24*60*60*1000);
						  dateIndex=formatTime(Dobj);
						  if(j==literal){
							liStr+=renderHavePrice(lowestPrice,"http://flight.mangocity.com/newjipiao-"+shortChar+"-"+dateIndex.replace(/-/g,'')+"-"+priceList[i][2]+".html",priceList[i][1],dateIndex.slice(-5));	   
							liNum++;
						  }
						  else{
							liStr+=renderNonePrice(dateIndex.slice(-5));
							liNum++; 
						   }
						  if(cutDate=dataInterval(dateIndex,limitDate),cutDate<=0){
							 break;
						   }
						 }
						 if(cutDate=dataInterval(dateIndex,limitDate),cutDate<=0){
							 break;
						  } 
				  }
				  var tempLiter=dataInterval(dateIndex,limitDate);
				  if(tempLiter>0){
					for(var k=1;k<=tempLiter;k++){
						dateIndex=formatTime(calculatDate(dateIndex,24*60*60*1000));
						liStr+=renderNonePrice(dateIndex.slice(-5));
						liNum++; 
					}
				  }
			}	  
		//构造余下的空的li标签
		for(var k=Math.ceil(liNum/7)*7-liNum;k>0;k--){
			liStr+="<li><div><span>&nbsp;</span><em>&nbsp;</em></div></li>";
			liNum++;
		  }
		  document.getElementById("ul_table").innerHTML=liStr;
		//处理函数 start  
		function  renderHavePrice(lowestPrice,href,price,date){
		   var tempStr='';
		  if(lowestPrice==price){
			tempStr+="<li><a href=\""+href+"\" target=\"_blank\"><i></i><span>&yen;"+price+"</span><em>"+date+"</em></a></li>" 
		  }else{
			tempStr+="<li><a href=\""+href+"\" target=\"_blank\"><span>&yen;"+price+"</span><em>"+date+"</em></a></li>" 
		  }
		  return tempStr;
		}
		function  renderNonePrice(dateStr){
		  var tempStr='';
		  tempStr="<li><div><span>暂无价格</span><em>"+dateStr+"</em></div></li>";
		  return tempStr;
		}
		function  cutZero(str){
		   return str.toString().substr(0,1)=='0'?parseInt(str.substring(1)):parseInt(str);
		}
		function  addZero(str){
		  return  str.toString().length==2 ? str: '0'+str;
		}
		function  dataInterval(str_1,str_2){
		  var strList_1=str_1.split('-');
		  var strList_2=str_2.split('-');
		 return (Date.parse(new Date(strList_2[0],strList_2[1]-1,strList_2[2]))-Date.parse(new Date(strList_1[0],strList_1[1]-1,strList_1[2])))/(24*60*60*1000);
		}
		function  calculatDate(str,iNum){
		   var strList_1=str.split('-');
		   return new Date(Date.parse(new Date(strList_1[0],strList_1[1]-1,strList_1[2]))+iNum);
		}
		function formatTime(date){
		  return date.getFullYear()+"-"+addZero(date.getMonth()+1)+"-"+addZero(date.getDate());
		}
		//处理函数 END 
	} 

	
	function getlowprice(haspricearr){
	    if(!haspricearr || !haspricearr.length){ return 0;}
	    var arr=haspricearr, len = arr.length > 30 ? 30 : arr.length, thelowest = 0;
		var parr = [];
		
		for(var k=0; k<len; k++){
		    parr.push(arr[k][1]);
		}

		parr.sort(function(a,b){ return parseInt(a) - parseInt(b);});

		
		return parr.shift();
	}
	
	function setemptylist(li, num){
		if(num%7 === 0){
			MGTOOL.addClass(li, 'list_lowhd');
		}	
	}
	
	function setlist(s_tw, e_tw, liobj, num, data, lowest){
	    var _s = s_tw, _e = e_tw, li = liobj, i = j = 0, htmlstr = pristr = ddstr = islow = '', urlstr = '###', diff = diff; 
		var dstr = data[0].split('-');
		MGTOOL.addClass(li, 'tk-on');
		urlstr = 'http://flight.mangocity.com/newjipiao-'+s_tw+'-'+e_tw+'-'+dstr.join('')+'-'+data[2]+'.html'
		pristr =  (data[1]=='0') ? '' : '&yen;'+data[1];
		ddstr = dstr[1]+'-'+dstr[2];
		islow = (!!lowest && lowest == data[1]) ? '<i class="icon-low"></i>' : '';
		if(pristr){
			htmlstr = '<a target="_blank" href="'+urlstr+'"><span><em class="num_pric">'+pristr+'</em></span><span class="low_date">'+ddstr+'</span>'+islow+'</a>';
		}

		li.innerHTML = htmlstr;			

		
	
	}
	

    return setDateString;

}();
if(MGTOOL.$id('blackct')){
	MGTOOL.$id('blackct').onclick = MGTOOL.$id('blackct').onfocus = function(){
		var key = getFlightThreeWordByCity(MGTOOL.$id('id_endCity_02').value);
		if(!!key &&  typeof key === 'string'){
			var url = 'http://fres.mangocity.com/js/flights/staticFile/flightShouye/'+ key +'-flight_shouye.js';
			MGTOOL.loadScript(url, function(){
				e_threeword = getFlightThreeWordByCity(MGTOOL.$id('id_startCity_02').value);
				MGTOOL.f_set_30datas(key, e_threeword, f_failer_tip);
			});
		}
	}
}
if(MGTOOL.$id('goct')){
	MGTOOL.$id('goct').onclick = MGTOOL.$id('goct').onfocus = function(){
		
		var key = getFlightThreeWordByCity(MGTOOL.$id('id_startCity_02').value);
		if(!!key &&  typeof key === 'string'){
			var url = 'http://fres.mangocity.com/js/flights/staticFile/flightShouye/'+ key +'-flight_shouye.js';
			MGTOOL.loadScript(url, function(){
				e_threeword = getFlightThreeWordByCity(MGTOOL.$id('id_endCity_02').value);
				MGTOOL.f_set_30datas(key, e_threeword, f_failer_tip);
			});
		}
		
	}
}


/***************
* 30天低价机票
* zhongweiming 2011-11-08
* end
***************/


//MGTOOL.f_set_30datas(1, 2);
//setDateString()

/*
	    this.target = config.target;
		this.commonlist = config.commonlist;
		this.list = config.list;
		this.inputNotes = config.inputNotes;

*/
/*
var start = MGTOOL.clone(MGTOOL.MGcitySelecter);

start.init({
    target : MGTOOL.$id('id_startCity'),
	wrapid : 'f_select',
	commonlist : commoncitysFlight,
	list : citysForFlight,
	inputNotes : '中文/拼音',
	isGroup : true

});

var end = MGTOOL.clone(MGTOOL.MGcitySelecter);

end.init({
    target : MGTOOL.$id('id_endCity'),
	wrapid : 'f_select',
	commonlist : commoncitysFlight,
	list : citysForFlight,
	inputNotes : '中文/拼音',
	isGroup : true

});
*/

 function startcallback(){
     $('#id_startCity').css("color", "#333");
	 if ($('#id_startCity').bgiframe) {
		$('#id_startCity').bgiframe();
	}
	 $('#id_endCity').focus();
 }
 
 function endcallback(){
     $('#id_endCity').css("color", "#333");
 }
 
 //var startcity=new CityPicker(citysForFlight,commoncitysFlight,["A-F","G-J","K-N","O-T","U-Z"],$("#id_startCity")[0],10,5,$("#id_dpt")[0], startcallback,"Y");
 //var endcity=new CityPicker(citysForFlight,commoncitysFlight,["A-F","G-J","K-N","O-T","U-Z"],$("#id_endCity")[0],10,5,$("#id_arr")[0], endcallback,"Y");



/*
* 30天低价数据
*/
var dysprice30 = [['PEK','北京','BEIJING','BJ'], ['SHA','上海','SHANGHAI','SH'], ['CAN','广州','GUANGZHOU','GZ'], ['SZX','深圳','SHENZHEN','SZ'], ['CTU','成都','CHENGDU','CD'], ['NKG','南京','NANJING','NJ'], ['WUH','武汉','WUHAN','WH'], ['CSX','长沙','CHANGSHA','CS'], ['KMG','昆明','KUNMING','KM'], ['XIY','西安','XIAN','XA'], ['CKG','重庆','CHONGQING','CQ'], ['TAO','青岛','QINGDAO','QD'], ['XMN','厦门','XIAMEN','XM'], ['HGH','杭州','HANGZHOU','HZ'], ['SYX','三亚','SANYA','SY'], ['DLC','大连','DALIAN','DL'], ['TSN','天津','TIANJIN','TJ'], ['KWE','贵阳','GUIYANG','GY'], ['FOC','福州','FUZHOU','FZ'], ['HAK','海口','HAIKOU','HK']];
var start_02 = MGTOOL.clone(MGTOOL.MGcitySelecter);


var price = MGTOOL.clone(MGTOOL.Selecter);

price._drawlist = function(){
	    if(!MGTOOL.$id(this.wrapid)){
		    var div = document.createElement('div');
			div.id = this.wrapid;
			div.className = "selecter";
			document.body.appendChild(div);
		}
		var slWrap = MGTOOL.$id(this.wrapid);
		slWrap.innerHTML = '<div id="prc_list" class="sllist"></div><iframe frameborder="0" marginheight="0" marginwidth="0" id="sl_iframe" style="position:absolute; left:-8px; top:-8px; overflow:hidden; width:106px; background:#fff; border:0; z-index:-1; opacity:0; filter:alpha(opacity = 0);"></iframe>';
		this.dp = MGTOOL.$id(this.wrapid);
		this.slList = MGTOOL.$id('prc_list');
		this.slIframe = MGTOOL.$id('prc_iframe');
};


var time  = MGTOOL.clone(MGTOOL.Selecter);

time._drawlist = function(){
	    if(!MGTOOL.$id(this.wrapid)){
		    var div = document.createElement('div');
			div.id = this.wrapid;
			div.className = "selecter";
			document.body.appendChild(div);
		}
		var slWrap = MGTOOL.$id(this.wrapid);
		slWrap.innerHTML = '<div id="tm_list" class="sllist"></div><iframe frameborder="0" marginheight="0" marginwidth="0" id="sl_iframe" style="position:absolute; left:-8px; top:-8px; overflow:hidden; width:106px; background:#fff; border:0; z-index:-1; opacity:0; filter:alpha(opacity = 0);"></iframe>';
		this.dp = MGTOOL.$id(this.wrapid);
		this.slList = MGTOOL.$id('tm_list');
		this.slIframe = MGTOOL.$id('tm_iframe');
};


var airline = MGTOOL.clone(MGTOOL.Selecter);

airline._drawlist = function(){
	    if(!MGTOOL.$id(this.wrapid)){
		    var div = document.createElement('div');
			div.id = this.wrapid;
			div.className = "selecter";
			document.body.appendChild(div);
		}
		var slWrap = MGTOOL.$id(this.wrapid);
		slWrap.innerHTML = '<div id="airline_list" class="sllist"></div><iframe frameborder="0" marginheight="0" marginwidth="0" id="sl_iframe" style="position:absolute; left:-8px; top:-8px; overflow:hidden; width:106px; background:#fff; border:0; z-index:-1; opacity:0; filter:alpha(opacity = 0);"></iframe>';
		this.dp = MGTOOL.$id(this.wrapid);
		this.slList = MGTOOL.$id('airline_list');
		this.slIframe = MGTOOL.$id('airline_iframe');
};



var fltype = MGTOOL.clone(MGTOOL.Selecter);

fltype._drawlist = function(){
	    if(!MGTOOL.$id(this.wrapid)){
		    var div = document.createElement('div');
			div.id = this.wrapid;
			div.className = "selecter";
			document.body.appendChild(div);
		}
		var slWrap = MGTOOL.$id(this.wrapid);
		slWrap.innerHTML = '<div id="typ_list" class="sllist"></div><iframe frameborder="0" marginheight="0" marginwidth="0" id="sl_iframe" style="position:absolute; left:-8px; top:-8px; overflow:hidden; width:106px; background:#fff; border:0; z-index:-1; opacity:0; filter:alpha(opacity = 0);"></iframe>';
		this.dp = MGTOOL.$id(this.wrapid);
		this.slList = MGTOOL.$id('typ_list');
		this.slIframe = MGTOOL.$id('typ_iframe');
};


//起飞时间  价格按钮箭头
function qf_chg_btn(num){
	var id_name="qf-button"+num;
	var tr_name="qf-content"+num;
	for(i=1;i<=2;i++){
		document.getElementById("qf-button"+i).className="";
		document.getElementById("qf-content"+i).style.display="none";
	}
	document.getElementById(id_name).className="";
	document.getElementById(tr_name).style.display="block";
}

function jg_chg_btn(num){
	var id_name="jg-button"+num;
	var tr_name="jg-content"+num;
	for(i=1;i<=2;i++){
		document.getElementById("jg-button"+i).className="";
		document.getElementById("jg-content"+i).style.display="none";
	}
	document.getElementById(id_name).className="";
	document.getElementById(tr_name).style.display="block";
}

//机票首页
function layer_show(layer_name,action){
if(action=="show"){
   document.getElementById(layer_name).style.display="block";
}
else if(action=="hide"){
   document.getElementById(layer_name).style.display="none";
}
}


function chg_btn(num){
	var id_name="godate_button"+num;
	var tr_name="godate_content"+num;
	for(i=1;i<=2;i++){
		document.getElementById("godate_button"+i);
		document.getElementById("godate_content"+i).style.display="none";
	}
	document.getElementById(id_name);
	document.getElementById(tr_name).style.display="block";
}


function city_chg_btn(num){
	var id_name="c_button"+num;
	var tr_name="c_content"+num;
	for(i=1;i<=7;i++){
		document.getElementById("c_button"+i).className="";
		document.getElementById("c_content"+i).style.display="none";
	}
	document.getElementById(id_name).className="ti_cton";
	document.getElementById(tr_name).style.display="block";
}